<?php   
	//TODO[elton] verificar funcionamento
	class XMLMapper {

	public static function retornaArray($data) {
		$data = file_get_contents($data);
		$ret = array ();

		$parser = xml_parser_create();
		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
		xml_parse_into_struct($parser, $data, $values, $tags);
		xml_parser_free($parser);

		$hash_stack = array ();
		print_r($values);

		foreach ($values as $key => $val) {
			switch ($val['type']) {
				case 'open' :
					array_push($hash_stack, $val['tag']);
					break;

				case 'close' :
					array_pop($hash_stack);
					break;

				case 'complete' :
					array_push($hash_stack, $val['tag']);
					if (!isset($val['value']))
						$val['value'] = "";
					eval ("\$ret['".implode($hash_stack, "']['")."'] = '{$val['value']}';");
					array_pop($hash_stack);
					break;
			}
		}

		return $ret;
	}
}

?>